package cn.kgc.service.Impl;

import cn.kgc.mapper.AppCategoryMapper;
import cn.kgc.pojo.AppCategory;
import cn.kgc.service.AppCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service("appCategoryService")
public class AppCategoryServiceImpl implements AppCategoryService {
    @Autowired
    private AppCategoryMapper appCategoryMapper;

    @Override
    public List<AppCategory> findCateListByPid(Integer pid) {
        Example example = new Example(AppCategory.class);
        if(pid == null){
            example.and().andIsNull("parentId"); //where parent_id is null
        }else {
            example.and().andEqualTo("parentId",pid);//where parent_id = pid
        }
        return appCategoryMapper.selectByExample(pid);
    }
}
